<?php
namespace Web\Controller;
use Think\Controller;
use Web\Controller\BaseController;
class NewsController extends BaseController {

    public function _initialize(){
        //如果session存在，传递用户信息
        $midiuser = session('midiuser');
        $this->assign('midiuser',$midiuser);
    }

    public function index(){
        $p = (!empty($json_arr['p']))?$json_arr['p']:1;
        $pnum = (!empty($json_arr['pnum']))?$json_arr['pnum']:10;

        $count = M('news')->count();
        $page = getpage($count,10);
        $news_arr = M('news')->order('news_id desc')->limit($page->firstRow, $page->listRows)->select();
        $this->assign('news_arr', $news_arr);
        $this->assign('page', $page->show());

        $this->display();
    }
}